package com.declum.archon.chunkserver.server.ds;

import java.sql.Date;

/**
 * This Class contains the Information when the client is pinging the
 * ChunkServer.
 * 
 * @author Clement
 * 
 */
public class PingInformation {

	/**
	 * Stores the total space available for ChunkServer
	 */
	int		totalSpace	= 0;

	/**
	 * Stores the used Spaces in ChunkServer
	 */
	int		usedSpace	= 0;

	/**
	 * Stores the Start time of ChunkServer
	 */
	long	startTime	= 0;

	/**
	 * Stores the last beat send to the MetaServer
	 */
	long	lastBeatAt	= 0;

	/**
	 * Name of the ChunkServer
	 */
	String	name		= "";

	/**
	 * Name of the Cluster to which the ChunkServer is registered
	 */
	String	clusterName	= "";

	/**
	 * @return total space in the ChunkServer
	 */
	public int getTotalSpace() {
		return this.totalSpace;
	}

	/**
	 * @param totalSpace
	 *            total space to be set for Ping Request
	 */
	public void setTotalSpace(int totalSpace) {
		this.totalSpace = totalSpace;
	}

	/**
	 * @return used space in the ChunkServer
	 */
	public int getUsedSpace() {
		return this.usedSpace;
	}

	/**
	 * @param usedSpace
	 *            used space to be set for Ping Request
	 */
	public void setUsedSpace(int usedSpace) {
		this.usedSpace = usedSpace;
	}

	/**
	 * @return start time of the ChunkServer
	 */
	public long getStartTime() {
		return this.startTime;
	}

	/**
	 * @param startTime
	 *            start time to be set for Ping Request
	 */
	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	public long getLastBeatAt() {
		return this.lastBeatAt;
	}

	public void setLastBeatAt(long lastBeatAt) {
		this.lastBeatAt = lastBeatAt;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getClusterName() {
		return this.clusterName;
	}

	public void setClusterName(String clusterName) {
		this.clusterName = clusterName;
	}

	@Override
	public String toString() {
		StringBuilder pingData = new StringBuilder(64);
		pingData.append("Name: " + this.name + "\t");
		pingData.append("ClusterName: " + this.clusterName + "\t");
		pingData.append("StartTime: " + new Date(this.startTime) + "\t");
		pingData.append("LastBeat: " + new Date(this.lastBeatAt) + "\t");
		pingData.append("TotalSpace: " + this.totalSpace + "\t");
		pingData.append("UsedSpace: " + this.usedSpace + "\t");
		return pingData.toString();
	}
}
